package com.hjy;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class MyConsumerDemo {

    public static void foreach(List<String> list, Consumer<String> consumer){
        list.forEach(v->consumer.accept(v));
    }

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("php");
        list.add("java");
        list.add("go");
        list.add("ruby");
        foreach(list, s -> System.out.println(s));

    }
}
